#include once "mud-gui/ui.bi"
#include once "mud-gui/widgets/GridLayout.bi"
#include once "mud-gui/widgets/Label.bi"
#include once "mud-gui/widgets/Canvas.bi"

'Example program testing GridLayout and Canvas
using ui

dim as GridLayout ptr mw
dim as label ptr label1
dim as Canvas ptr cv

if initScreen("Drawable Canvas Example") = 0 then
	print "unable to initialize screen."
	end 23
end if

mw = new GridLayout

label1 = new label
label1->setText = "Draw Something in the black area!"
label1->setAlignment = alignment.center

cv = new Canvas
cv->setDrawable = 1 'defaults to not allowing the mouse to draw
cv->setFgColor = rgb(255,0,0)
mw->sizeGrid(5,5)

ConsolePrint( "1: " & mw->placeWidget( toBaseWidget(label1), 1, 1, 5, 1 ) )
ConsolePrint( "2: " & mw->placeWidget( toBaseWidget(cv), 1, 2, 5, 5 ) )

'Canvas widget isn't sized until it is placed in a layout, so a draw call before
'here would fail.
cv->drawCircle( 100,100,50 )
cv->drawFilledCircle( 200,100,10,rgb(255,0,0) )
cv->drawLine( 1, 1, 20, 20 )
cv->drawBox( 20, 20, 30, 30 )
cv->drawFilledBox( 150,10, 160, 20 )

end RunGUI( toBaseWidget(mw) )
